package team.wuyou.util;

import java.util.Random;
import java.util.UUID;

public class UuidUtil {

    public static String get32UUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    //验证码
    public static String getVerificationCode(Integer lenth) {
        String str = "0123456789";
        Random random1 = new Random();
        //指定字符串长度，拼接字符并toString
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < lenth; i++) {
            //获取指定长度的字符串中任意一个字符的索引值
            int number = random1.nextInt(str.length());
            //根据索引值获取对应的字符
            char charAt = str.charAt(number);
            sb.append(charAt);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(UuidUtil.getVerificationCode(6));
    }

}
